package app.project.streetlensproject.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.ArrayList;

import android.content.Context;
import android.text.Html;
import android.view.LayoutInflater;
import android.widget.TextView;
import app.project.streetlensproject.R;

public class ItemListPlaceDirectionAdapter extends BaseAdapter {

	private ArrayList<String> mArrDirection;
	private LayoutInflater mLayoutInflater;
	public ItemListPlaceDirectionAdapter(Context context, ArrayList<String> directions) {
		this.mArrDirection=directions;		
		mLayoutInflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return mArrDirection.size();
	}

	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	public class ViewHolder {
		public TextView textViewNum;
		public TextView textViewDetail;
	}

	public View getView(final int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		final ViewHolder view;
		if (convertView == null) {
			view = new ViewHolder();
			convertView = mLayoutInflater.inflate(R.layout.item_list_place_direction,
					null);

			view.textViewNum = (TextView) convertView
					.findViewById(R.id.textViewNum);
			view.textViewDetail = (TextView) convertView
					.findViewById(R.id.textViewDirectionDetail);

			convertView.setTag(view);
		} else {
			view = (ViewHolder) convertView.getTag();
		}

		view.textViewNum.setText(String.valueOf(position+1));
		view.textViewDetail.setText(Html.fromHtml(mArrDirection.get(position)));
		return convertView;
	}

}

